class Solution {
    public:
        int path,_target,cnt;
        int findTargetSumWays(vector<int>& nums, int target) {
            _target = target;
            dfs(0,nums);
            return cnt;
        }
        void dfs(int pos,vector<int>& nums){
            if(pos == nums.size()){
                if(path == _target)  cnt++;
                return;
            }
            path+=nums[pos];
            dfs(pos+1,nums);
            path-=nums[pos];//恢复现场
            path-=nums[pos];
            dfs(pos+1,nums);
            path+=nums[pos];//恢复现场
        }
    
    };